package utilities;


/**
 * @author Mathieu Rousseau
 * @email mathieu.rousseau3@mail.mcgill.ca
 */


/** ------------------------------------------------------------------------------------------------------------------
 * start of StructureManipulator class
 * ------------------------------------------------------------------------------------------------------------------  **/
public class StructureManipulator {

	
	/*  global parameters  */
	private static final String inputPath = "StructureManipulator/Input/";
	private static final String outputPath = "StructureManipulator/Output/";
	private static PDButility pdb = new PDButility();
	private static String mirrorOutputPrefix = "";
	private static String zoomOutputPrefix = "";
	private static String structureFilename;
	/*  end of global parameters  */
	
	
	/*  start of printStructure method  */
	private static void printStructure(String structureFilename){
		double[][] structure = pdb.getStructure(inputPath + structureFilename);		
		System.out.println(pdb.toString(structure));		
	}/*  end of printStructure method  */
	
	
	/*  start of zoomStructures method  */
	private static void zoomStructures(double zoomFactor, int numberOfStructures){
		for(int i=0; i<=numberOfStructures; i++){			
			zoomStructure(zoomFactor, pdb.getDefaultFilenameForIndex(i));
		}		
	}/*  end of zoomStructures method  */
	
	
	/*  start of zoomStructure method  */
	private static void zoomStructure(double zoomFactor, String structureFilename){
		double[][] structure = pdb.getStructure(inputPath + structureFilename);
		
		structure = pdb.zoomStructure(structure, zoomFactor);
		
		pdb.writeStructure(outputPath + zoomOutputPrefix + structureFilename, structure, pdb.getHeader(inputPath + structureFilename) + "\tZoomStructure[" + zoomFactor + "x]");		
	}/*  end of zoomStructure method  */
	
	
	/*  start of mirrorStructures method  */
	private static void mirrorStructures(int numberOfStructures){
		for(int i=0; i<=numberOfStructures; i++){			
			mirrorStructure(pdb.getDefaultFilenameForIndex(i));
		}
	}/*  end of mirrorStructures method  */
	
	
	/*  start of mirrorStructure method  */
	private static void mirrorStructure(String structureFilename){
		double[][] structure = pdb.getStructure(inputPath + structureFilename);
		
		structure = pdb.mirrorStructure(structure);
		
		pdb.writeStructure(outputPath + mirrorOutputPrefix + structureFilename, structure, pdb.getHeader(inputPath + structureFilename) + "\tmirrored");
	}/*  end of mirrorStructure method  */
	
	
	/*  start of main method  */
	public static void main(String[] args) {
		
		
		/**
		 * 		SET THE STRUCTURE FILENAME
		 */
//		structureFilename = "best_structure.pdb";
		structureFilename = "1.pdb";
		
		
		
		/**
		 * 		SET THE ZOOM FACTOR
		 */
		double zoomFactor = 10.0;
		
		
		/**
		 * 		SET THE NUMBER OF STRUCTURES
		 */
		int numberOfStructures = 0;
		
		
		/**
		 * 		SET THE ZOOM OUTPUT FILENAME PREFIX
		 */
		zoomOutputPrefix = "zoom_";
		
		
		/**
		 * 		SET THE MIRROR OUTPUT FILENAME PREFIX
		 */
		mirrorOutputPrefix = "mirror_";
		
		
		
		
		//  print the structure to the console
//		printStructure(structureFilename);
		
		
		//  zoom the specified structure(s)
//		zoomStructure(zoomFactor, structureFilename);
//		zoomStructures(zoomFactor, numberOfStructures);
		
		
		//  mirror the specified structure(s)
		mirrorStructure(structureFilename);
//		mirrorStructures(numberOfStructures);
		
		System.out.println("Done!");
	}/*  end of main method  */

}/*  end of StructureManipulator class  */
